home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / network / pktdrvtp.zip / PKTDRVR.ZIP / PKTDRVR.PAS < prev    next >
Pascal/Delphi Source File  |  1993-10-08  |  26KB  |  653 lines

  1. UNIT PKTDRVR;
  2. {
  3. ╔════════════════════════════════╤═════════════════════════════════════╗
  4. ║ Filename       : PKTDRVR.PAS   │  Program / Unit : [U]               ║
  5. ║ Description    : Turbo Pascal  └─────────────────────────────────────╢
  6. ║                  Object to interface with Crynrware packet drivers.  ║
  7. ║                                                                      ║
  8. ╟──────────────────────────────────────────────────────────────────────╢
  9. ║ Compiler       : Turbo Pascal 7.0                                    ║
  10. ║ OS-Version     : MS-DOS 6.0                                          ║
  11. ║ Last edit      : 08-Oct-93                                           ║
  12. ║ Version        : 1.0                                                 ║
  13. ╟──────────────────────────────────────────────────────────────────────╢
  14. ║ Author         : Oliver Rehmann                                      ║
  15. ║ Copyright      : (C) 1993 Oliver Rehmann                             ║
  16. ║                                                                      ║
  17. ║ Released to public domain.                                           ║
  18. ║ The author can not be held responsible for any damages resulting     ║
  19. ║ from the use of this software.                                       ║
  20. ╚══════════════════════════════════════════════════════════════════════╝
  21. }
  22.  
  23. INTERFACE
  24.  
  25. USES DOS,OBJECTS;
  26.  
  27. {$I PACKET.INC}
  28.  
  29. CONST
  30.      Pkt_Sig  : String[08] = 'PKT DRVR';
  31.      ParamLen : Byte       = 14;
  32.  
  33. TYPE TPKTSTATUS    = (NO_PKTDRVR,INITIALIZED,NOT_INITIALIZED);
  34.      TACCESSTYPE   = RECORD
  35.                if_class      : Byte;    { Interface class  }
  36.                if_type       : Word;    { Interface Type   }
  37.                if_number     : Byte;    { Interface number }
  38.                type_         : Pointer;
  39.                typelen       : Word;    { length of type_, set to 0 if
  40.                           you want to receive all pkts }
  41.                receiver      : Pointer; { receive handler }
  42.              END;
  43.  
  44.       TPKTPARAMS   = RECORD
  45.                major_rev     : Byte; { Major revision ID of packet specs }
  46.                minor_rev     : Byte; { Minor revision ID of packet specs }
  47.                length        : Byte; { Length of structure in Bytes      }
  48.                addr_len      : Byte; { Length of a MAC address           }
  49.                mtu           : Word; { MTU, including MAC headers        }
  50.                multicast_aval: Word; { buffer size for multicast addr.   }
  51.                rcv_bufs      : Word; { (# of back-to-back MTU rcvs) - 1  }
  52.                xmt_bufs      : Word; { (# of successive xmits) - 1       }
  53.                int_num       : Word; { Interrupt # to hook for post-EOI
  54.                            processing, 0 == none }
  55.  
  56.              END;
  57.  
  58.       TDRVRINFO    = RECORD
  59.                Version       : Word; { Packet driver version   }
  60.                Class         : Byte; { Driver class  }
  61.                Type_         : Word; { Driver type   }
  62.                Number        : Byte; { Driver number }
  63.                pName         : Pointer;
  64.                Functionality : Byte; { How good is this driver }
  65.              END;
  66.  
  67.        TSTATISTICS = RECORD
  68.                packets_in    : LongInt;
  69.                packets_out   : LongInt;
  70.                bytes_in      : LongInt;
  71.                bytes_out     : LongInt;
  72.                errors_in     : LongInt;
  73.                errors_out    : LongInt;
  74.                packets_lost  : LongInt;
  75.              END;
  76.  
  77.        TPKTDRVR = OBJECT(TOBJECT)
  78.  
  79. private
  80.           pktInt         : Integer;
  81.           pktHandle      : Integer;
  82.           pktRecvHandler : Pointer;
  83.           pktStatus      : TPKTSTATUS;
  84.           pktError       : Byte;
  85.           pktRegs        : Registers;
  86.  
  87.           pktAccessInfo  : TACCESSTYPE;
  88.  
  89.           PROCEDURE   TestForPktDriver;
  90. public
  91.           CONSTRUCTOR Init(IntNo : Integer);
  92.           DESTRUCTOR  Done; VIRTUAL;
  93.  
  94.           PROCEDURE   ScanForPktDriver;
  95.  
  96.           FUNCTION    GetStatus                          : TPKTSTATUS;
  97.           FUNCTION    GetError                           : Byte;
  98.           FUNCTION    GetHandle                          : Word;
  99.  
  100.           PROCEDURE   GetAccessType   (VAR pktAccessType : TACCESSTYPE);
  101.           PROCEDURE   DriverInfo      (VAR pktInfo       : TDRVRINFO  );
  102.  
  103.           PROCEDURE   AccessType      (VAR pktAccessType : TACCESSTYPE);
  104.           PROCEDURE   ReleaseType;
  105.           PROCEDURE   TerminateDriver;
  106.  
  107.           PROCEDURE   GetAddress      (Buffer : Pointer;BufLen : Word; VAR BufCopied : Word);
  108.           PROCEDURE   ResetInterface;
  109.           PROCEDURE   GetParameters   (VAR pktParams : TPKTPARAMS);
  110.  
  111.           PROCEDURE   SendPkt         (Buffer : Pointer;BufLen : Word );
  112.           PROCEDURE   As_SendPkt      (Buffer : Pointer;BufLen : Word;Upcall : Pointer     );
  113.  
  114.           PROCEDURE   SetRCVmode      (Mode   : Word);
  115.           FUNCTION    GetRCVmode              : Word;
  116.  
  117.           PROCEDURE   SetMulticastList(VAR mcList : Pointer; VAR mcLen : Word);
  118.           PROCEDURE   GetMulticastList(VAR mcList : Pointer; VAR mcLen : Word);
  119.  
  120.           PROCEDURE   GetStatistics   (VAR pktStatistics : TSTATISTICS       );
  121.           PROCEDURE   SetAddress      (Address : Pointer; VAR AddrLen  : Word);
  122.  
  123.           END;
  124.  
  125. IMPLEMENTATION
  126.  
  127. {╔══════════════════════════════════════════════════════════════════════╗
  128.  ║ CONSTRUCTOR Init                                                     ║
  129.  ╟─────────────────┬────────────────────────────────────────────────────╢
  130.  ║ Description   : │ Initializes packet driver object                   ║
  131.  ║                 │                                                    ║
  132.  ╟─────────────────┼────────────────────────────────────────────────────╢
  133.  ║ Creation date : │ 13-SEPT-93                                         ║
  134.  ╚═════════════════╧════════════════════════════════════════════════════╝}
  135. CONSTRUCTOR TPKTDRVR.Init(IntNo : Integer);
  136. BEGIN
  137.   Inherited Init;
  138.  
  139.   pktInt    := IntNo;
  140.   pktStatus := NOT_INITIALIZED;
  141.   FillChar(pktAccessInfo,SizeOf(pktAccessInfo),#00);
  142.  
  143.   TestForPktDriver;
  144. END;
  145.  
  146. {╔══════════════════════════════════════════════════════════════════════╗
  147.  ║ DESTRUCTOR Done                                                      ║
  148.  ╟─────────────────┬────────────────────────────────────────────────────╢
  149.  ║ Description   : │ Calls inherited destructor of TOBJECT              ║
  150.  ║                 │                                                    ║
  151.  ╟─────────────────┼────────────────────────────────────────────────────╢
  152.  ║ Creation date : │ 13-SEPT-93                                         ║
  153.  ╚═════════════════╧════════════════════════════════════════════════════╝}
  154. DESTRUCTOR TPKTDRVR.Done;
  155. BEGIN
  156.  
  157.   { Release allocated handle }
  158.   IF (pktStatus = INITIALIZED) THEN
  159.   BEGIN
  160.     ReleaseType;
  161.   END;
  162.  
  163.   Inherited Done;
  164. END;
  165.  
  166. {╔══════════════════════════════════════════════════════════════════════╗
  167.  ║ FUNCTION GetStatus : TPKTSTATUS                                      ║
  168.  ╟─────────────────┬────────────────────────────────────────────────────╢
  169.  ║ Description   : │ Returns current object status                      ║
  170.  ║                 │                                                    ║
  171.  ╟─────────────────┼────────────────────────────────────────────────────╢
  172.  ║ Creation date : │ 13-SEPT-93                                         ║
  173.  ╚═════════════════╧════════════════════════════════════════════════════╝}
  174. FUNCTION TPKTDRVR.GetStatus : TPKTSTATUS;
  175. BEGIN
  176.   GetStatus := pktStatus;
  177. END;
  178.  
  179. {╔══════════════════════════════════════════════════════════════════════╗
  180.  ║ FUNCTION GetAccessType                                               ║
  181.  ╟─────────────────┬────────────────────────────────────────────────────╢
  182.  ║ Description   : │ Returns information about type of interface, class,║
  183.  ║                 │ interface number.                                  ║
  184.  ╟─────────────────┼────────────────────────────────────────────────────╢
  185.  ║ Creation date : │ 13-SEPT-93                                         ║
  186.  ╚═════════════════╧════════════════════════════════════════════════════╝}
  187. PROCEDURE TPKTDRVR.GetAccessType(VAR pktAccessType : TACCESSTYPE);
  188. BEGIN
  189.   pktAccessType := pktAccessInfo;
  190. END;
  191.  
  192. {╔══════════════════════════════════════════════════════════════════════╗
  193.  ║ PROCEDURE TestForPktDriver;                                          ║
  194.  ╟─────────────────┬───────────────────────────────────────────────────